package com.ljs.shardingspheredemo.config.algorithm;

import org.apache.shardingsphere.api.sharding.standard.RangeShardingAlgorithm;
import org.apache.shardingsphere.api.sharding.standard.RangeShardingValue;

import java.sql.Array;
import java.util.Arrays;
import java.util.Collection;

/**
 * 配置标准的分库分表的时候
 */
public class MyRangeTableShardingalgorithm implements RangeShardingAlgorithm<Long> {


    @Override
    public Collection<String> doSharding(Collection<String> collection, RangeShardingValue<Long> rangeShardingValue) {
       String  logicTableName=     rangeShardingValue.getLogicTableName();
// String userId=rangeShardingValue.getColumnName();
      Long lowerEndpoint=  rangeShardingValue.getValueRange().lowerEndpoint();//下限
     Long upperEndpoint=   rangeShardingValue.getValueRange().upperEndpoint();//上限
      //有表  _1,_2,_3
        return Arrays.asList(logicTableName+"_1",logicTableName+"_2",logicTableName+"_3");

    }
}
